#include "pub_defs.h"
#include "calc_xv_baseline.h"
#include <iostream>

int main(int argc, char* argv[]) {
    int tmax = std::atoi(argv[2]);
    int n = std::atoi(argv[1]);
    double m = M;
    double dt = DT;
    TD* x = new TD[n];
    TD* v = new TD[n];
    for (int i = 0; i < n; i++) {
        x[i] = TD(i, i+1, i+2);
        v[i] = TD(i+1, i+2, i+3);
    }
    
    // 写入输入文件
    if (write_infile(x, v, n)) {
        std::cerr << "Failed to open input file for writing" << std::endl;
        delete[] x;
        delete[] v;
        return 1;
    }
    double begin_time = wall_time();
    calc_xv_baseline(x, v, n, tmax, m, dt);
    double last_time = wall_time()-begin_time;
    std::cout <<"n:"<<n<<" tmax: "<<tmax << " gen data baseline Time elapsed: " << last_time << " seconds." << std::endl;

    // 写入输出文件
    if (write_outfile(x, v, n)) {
        std::cerr << "Failed to open output file for writing" << std::endl;
        delete[] x;
        delete[] v;
        return 1;
    }

    delete[] x;
    delete[] v;
    return 0;
}